package com.sunshine.spring.jdbc.template;

import com.sunshine.spring.jdbc.model.Customer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * main方法类
 *
 * @Author: WeiHong
 * @Date: 2017/3/16 15:21
 */
public class App {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/spring-jdbc.xml");
        CustomerDaoImpl dao = (CustomerDaoImpl) ctx.getBean("jdbcCustomerDao");
        //插入数据
        //Customer customer = new Customer(4, "test1" , 22);
        //dao.insert(customer);

        //查询
        //Customer customer = dao.findByCustomerId(1);
        //System.out.println(customer.toString());

        //Customer customer = dao.findByCustomerId2(1);
        //System.out.println(customer.toString());

        //单列名查询
        //String customerName = dao.findCustomerNameByID(1);
        //System.out.println(customerName);

        //查询所有
        List<Customer> all = dao.findAll();
        System.out.println(all.toString());


    }
}
